#include <iostream>
#include <vector>
#include <set>

void sparseStr(std::string str, std::vector<std::pair<std::string, std::set<char>>> &str_set)
{
    int i = 0;
    while (i < str.size())
    {
        std::set<char> tmp_set;
        std::string tmp_str;
        while (i < str.size() && str[i] != ',')
        {
            tmp_str.push_back(str[i]);
            tmp_set.insert(str[i]);
            i++;
        }
        i++;
        str_set.push_back({tmp_str, tmp_set});
    }
}

int main()
{
    std::string guess_str;
    std::string real_str;

    std::getline(std::cin, guess_str);
    std::getline(std::cin, real_str);

    std::vector<std::pair<std::string, std::set<char>>> guess_set;
    std::vector<std::pair<std::string, std::set<char>>> real_set;
    sparseStr(guess_str, guess_set);
    sparseStr(real_str, real_set);

    for (int i = 0; i < guess_set.size(); i++)
    {
        bool find = false;
        for (int j = 0; j < real_set.size(); j++)
        {
            // std::cout << real_set[j].first << std::endl;
            if (guess_set[i].second == real_set[j].second)
            {
                find = true;
                std::cout << real_set[j].first;
                break;
            }
        }
        if (!find)
        {
            std::cout << "not found";
        }
        if (i != guess_set.size() - 1)
        {
            std::cout << ",";
        }
    }
    std::cout << std::endl;

    return 0;
}